package com.chaofan.messagebook.mapper;

import com.chaofan.messagebook.entity.Message;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author 李超凡
 * @since 2022/4/18 23:02
 */
@Mapper
public interface MessageMapper {

    @Select("select * from message limit #{page},#{size};")
    List<Message> queryByPage(@Param("page") Integer page, @Param("size") Integer size);

    @Insert("insert into message (id, author, mail, `time`, content, reply) values (#{id},#{author},#{mail},#{time},#{content},#{reply});")
    @Options(useGeneratedKeys = true,keyProperty = "id",keyColumn = "id")
    int insert(Message message);

    @Delete("delete from message where id=#{id};")
    int deleteById(Integer id);

}
